<template>
  <div class="serverMonitoring">
    <div class="flexBet">
      <!-- 实时数据看板 -->
      <div class="realTimeDataDashboards">
        <div class="t1">实时数据看板<span> ( 每分钟更新 )</span></div>
        <div class="flex t2">
          <div class="t2_1" style="background: rgba(0, 154, 147, 1)"></div>
          <div class="t2_2">平均数据</div>
          <div class="t2_1" style="background: rgba(60, 177, 232, 1)"></div>
          <div class="t2_2">最高数据</div>
        </div>
      </div>
      <!-- cpu使用率 -->
      <div class="flex cpuUsage card">
        <!-- 扇形 -->
        <div class="sectorChart">
          <circle-progressbar
            id="sectorChart1"
            barColor="rgba(26, 213, 152, 1)"
            backgroundColor="rgba(241, 244, 249, 1)"
            :width="50"
            :radius="15"
            :progress="80"
            :isAnimation="false"
          ></circle-progressbar>
          <div class="tip">cpu使用率</div>
        </div>
        <!-- 折线图 -->
        <div
          class="lineChart"
          id="lineChart1"
          style="width: 470px; height: 190px; margin-left: 25px"
        ></div>
      </div>
    </div>
    <div class="flexBet">
      <!-- 内存使用率 -->
      <div class="flex card">
        <!-- 扇形 -->
        <div class="sectorChart">
          <circle-progressbar
            id="sectorChart2"
            barColor="rgba(26, 213, 152, 1)"
            backgroundColor="rgba(241, 244, 249, 1)"
            :width="50"
            :radius="15"
            :progress="80"
            :isAnimation="false"
          ></circle-progressbar>
          <div class="tip">内存使用率</div>
        </div>
        <!-- 折线图 -->
        <div
          class="lineChart"
          id="lineChart2"
          style="width: 470px; height: 190px; margin-left: 25px"
        ></div>
      </div>
      <!-- 磁盘使用率 -->
      <div class="flex card">
        <!-- 扇形 -->
        <div class="sectorChart">
          <circle-progressbar
            id="sectorChart3"
            barColor="rgba(26, 213, 152, 1)"
            backgroundColor="rgba(241, 244, 249, 1)"
            :width="50"
            :radius="15"
            :progress="80"
            :isAnimation="false"
          ></circle-progressbar>
          <div class="tip">磁盘使用率</div>
        </div>
        <!-- 折线图 -->
        <div
          class="lineChart"
          id="lineChart3"
          style="width: 470px; height: 190px; margin-left: 25px"
        ></div>
      </div>
    </div>
    <div class="flexBet">
      <!-- 负载状态 -->
      <div class="flex card">
        <!-- 扇形 -->
        <div class="sectorChart">
          <circle-progressbar
            id="sectorChart4"
            barColor="rgba(26, 213, 152, 1)"
            backgroundColor="rgba(241, 244, 249, 1)"
            :width="50"
            :radius="15"
            :progress="80"
            :isAnimation="false"
          ></circle-progressbar>
          <div class="tip">负载状态</div>
        </div>
        <!-- 折线图 -->
        <div
          class="lineChart"
          id="lineChart4"
          style="width: 470px; height: 190px; margin-left: 25px"
        ></div>
      </div>
      <!-- 带宽使用率 -->
      <div class="flex card">
        <!-- 扇形 -->
        <div class="sectorChart">
          <circle-progressbar
            id="sectorChart5"
            barColor="rgba(26, 213, 152, 1)"
            backgroundColor="rgba(241, 244, 249, 1)"
            :width="50"
            :radius="15"
            :progress="80"
            :isAnimation="false"
          ></circle-progressbar>
          <div class="tip">带宽使用率</div>
        </div>
        <!-- 折线图 -->
        <div
          class="lineChart"
          id="lineChart5"
          style="width: 470px; height: 190px; margin-left: 25px"
        ></div>
      </div>
    </div>
  </div>
</template>

<script>
import circleProgressbar from "vue-circleprogressbar";
import * as echarts from "echarts";
export default {
  name: "serverMonitoring",
  components: {
    circleProgressbar,
  },
  data() {
    return {};
  },

  mounted() {
    let lineChart1 = echarts.init(document.getElementById("lineChart1"));
    let lineChart2 = echarts.init(document.getElementById("lineChart2"));
    let lineChart3 = echarts.init(document.getElementById("lineChart3"));
    let lineChart4 = echarts.init(document.getElementById("lineChart4"));
    let lineChart5 = echarts.init(document.getElementById("lineChart5"));
    let option = {
      tooltip: {
        trigger: "axis",
      },
      grid: {
        left: 30,
        top: 10,
        bottom: 20,
        right: 20,
      },
      xAxis: {
        type: "category",
        data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
      },
      yAxis: {
        type: "value",
      },
      series: [
        {
          name: "最高数据",
          type: "line",
          lineStyle: {
            color: "rgba(60, 177, 232, 1)",
          },
          smooth: 0.6,
          data: [120, 132, 101, 134, 90, 230, 210],
        },
        {
          name: "平均数据",
          lineStyle: {
            color: "rgba(0, 154, 147, 1)",
          },
          type: "line",
          smooth: 0.6,
          data: [220, 182, 191, 234, 290, 330, 310],
        },
      ],
    };
    lineChart1.setOption(option);
    lineChart2.setOption(option);
    lineChart3.setOption(option);
    lineChart4.setOption(option);
    lineChart5.setOption(option);
  },

  methods: {},
};
</script>

<style lang="scss" scoped>
.card {
  height: 190px;
  margin-bottom: 50px;
}
.tip {
  margin-top: 12px;
  font-size: 16px;
  font-weight: 400;
  text-align: center;
  color: rgba(39, 196, 120, 1);
}
::v-deep .sectorChart {
  width: 154px;
  height: 154px;
  svg {
    width: 154px;
    height: 154px;
  }
  .content {
    position: relative;
  }
  .center_text {
    top: 50%;
    transform: translate(-50%, -50%);
    left: 50%;
    position: absolute;
    font-size: 30px;
    font-weight: 400;
    color: rgba(39, 196, 120, 1);
  }
}

.serverMonitoring {
  box-sizing: border-box;
  padding: 60px 6%;
}
.realTimeDataDashboards {
  padding: 0 0 0 110px;
  .t1 {
    margin-top: 46px;
    font-size: 40px;
    font-weight: 400;
    color: rgba(39, 196, 120, 1);
    span {
      font-size: 20px;
    }
  }
  .t2 {
    margin-top: 15px;
    .t2_1 {
      width: 22px;
      height: 22px;
      border-radius: 2px;
      margin-right: 15px;
    }
    .t2_2 {
      font-size: 14px;
      font-weight: 400;
      line-height: 22px;
      color: rgba(128, 128, 128, 1);
      margin-right: 15px;
    }
  }
}
</style>
